//
//  StatusBottomView.swift
//  微博项目
//
//  Created by zhaoyinpeng on 16/3/15.
//  Copyright © 2016年 zhaoyinpeng. All rights reserved.
//

import UIKit

class StatusBottomView: UIView {
    
    //.MARK: 按钮监听事件
    @objc private func repostBtnDidClikc() {
        //.页面跳转
        let temp = TempViewController()
        
        //.设置底部tabbar隐藏
        temp.hidesBottomBarWhenPushed = true
        //.使用导航视图控制 跳转
        navController()?.pushViewController(temp, animated: true)
        
        
    }
    
    
   //.重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    //.默认实现报错
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    //.MARK: 设置UI界面
    private func setupUI() {
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        addSubview(repostBtn)
        addSubview(commentBtn)
        addSubview(unlike)
        
        
        //.三个按钮平分视图
        repostBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.left.equalTo(self)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.left.equalTo(repostBtn.snp_right)
            make.width.equalTo(repostBtn.snp_width)
        }
        
        unlike.snp_makeConstraints { (make) -> Void in
            make.top.bottom.right.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
        
        let line1 = sepView()
        let line2 = sepView()
        
        addSubview(line1)
        addSubview(line2)
        
        let w: CGFloat = 0.3
        //.设置约束
        line1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.centerY.equalTo(self.snp_centerY)
            //.设置宽度
            make.width.equalTo(w)
        }
        line2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.centerY.equalTo(self.snp_centerY)
            //.设置宽度
            make.width.equalTo(w)
        }
        
        
        //.添加按钮监听事件
        repostBtn.addTarget(self, action: "repostBtnDidClikc", forControlEvents: .TouchUpInside)

    }
    
    
    //.分割线
    private func sepView() -> UIView {
        let lineView = UIView()
        
        //.设置背景色
         lineView.backgroundColor = UIColor.lightGrayColor()
        return lineView
    }
    
    //.MARK: 懒加载子视图
    private lazy var repostBtn: UIButton = UIFactory.buttonWithtitle("转发", backImageName: nil, textColor: UIColor.darkGrayColor(), fontSize: 12, imageName: "timeline_icon_retweet")
    private lazy var commentBtn: UIButton = UIFactory.buttonWithtitle("评论", backImageName: nil, textColor: UIColor.darkGrayColor(), fontSize: 12, imageName: "timeline_icon_comment")
    private lazy var unlike: UIButton = UIFactory.buttonWithtitle("点赞", backImageName: nil, textColor: UIColor.darkGrayColor(), fontSize: 12, imageName: "timeline_icon_unlike")
    
}
